﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_DeleteDocument]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_DeleteDocument];
GO
CREATE PROCEDURE [dbo].[sproc_DeleteDocument]
    @DocIDs nvarchar(3000),
    @DeleteType int =0
/*
=============================================================
功能:    删除文档
参数:
    @DocIDs nvarchar(3000)        :    被删除文档的ID集合
    @DeleteType int =0        :    删除类型
备注:    (0>>删除标记，1>>物理删除)
=============================================================
*/
AS
DECLARE @SQL nvarchar(4000)
IF @DeleteType=0
BEGIN
    --做删除标记
    SET @SQL = 'UPDATE uds_document SET DocDeletion=1 WHERE docid in (' + @DocIDs + ')'
    EXEC (@SQL)
    RETURN 1
END
ELSE
BEGIN
    --删除文件记录
    SET @SQL = 'DELETE FROM uds_document WHERE docid in (' + @DocIDs + ')'
    EXEC (@SQL)
    --删除附件记录
    SET @SQL = 'DELETE FROM uds_files WHERE docid in (' + @DocIDs + ')'
    EXEC (@SQL)
    RETURN 2
END